import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 轮播图信息 */
export interface Picture {
          id: number; // 图片id
          url: string; // 图片路径
          link: string; // 跳转路径
          expirationDate: string | Dayjs; // 有效期
          detail: string; // 描述
          number: number; // 展示顺序
          displayDuration: number; // 展示时长
          status: number; // 轮播图状态
  }

// 轮播图 API
export const PictureApi = {
  // 查询轮播图分页
  getPicturePage: async (params: any) => {
    return await request.get({ url: `/train/picture/page`, params })
  },

  // 查询轮播图详情
  getPicture: async (id: number) => {
    return await request.get({ url: `/train/picture/get?id=` + id })
  },

  // 新增轮播图
  createPicture: async (data: Picture) => {
    return await request.post({ url: `/train/picture/create`, data })
  },

  // 修改轮播图
  updatePicture: async (data: Picture) => {
    return await request.put({ url: `/train/picture/update`, data })
  },

  // 删除轮播图
  deletePicture: async (id: number) => {
    return await request.delete({ url: `/train/picture/delete?id=` + id })
  },

  /** 批量删除轮播图 */
  deletePictureList: async (ids: number[]) => {
    return await request.delete({ url: `/train/picture/delete-list?ids=${ids.join(',')}` })
  },

  // 导出轮播图 Excel
  exportPicture: async (params) => {
    return await request.download({ url: `/train/picture/export-excel`, params })
  },
}